<template>
  <div>
    <!-- <pull-to
       :bottom-load-method="infiniteHandler"
       :bottom-config="BOTTOM_DEFAULT_CONFIG">-->
    <div style="width: 100%;height: auto;background: #F452E7;padding-top: 10vw">
      <div class="bodys" v-for="(v,i) in goodList" :key="i" style="margin-top: 4vw" @click="click(v)" >
        <div class="left">
          <img :src=v.thum_img alt="">
        </div>
        <div class="right">
          <p style="color: #333;font-size: 15px;" class="goodName">{{v.good_name}}</p>
          <p style="margin-top: 10vw;" class="price">
            <span style=" font-size: 18px;color: #ff4c50;text-decoration: none" class="sellPrice">￥{{v.sell_price}}</span><br/>
            <span class="marketPrice">￥{{v.market_price}}</span>
            <button style="background: linear-gradient(#59057B,#AB0E86);">立即购</button>
            <!-- <button style=" background: linear-gradient(#59057B,#AB0E86);" v-if="time">立即购</button>
             <button style=" background: linear-gradient(rgba(89,5,123,.5),rgba(171,14,134,.5));">等待开售</button>-->
          </p>
        </div>
      </div>
    </div>
    <!-- </pull-to>-->

    <div style="width: 100vw;height: 4vw;background: #F452E7;"></div>
  </div>

</template>

<script>
  import request from '../../request/index'
  import PullTo from 'vue-pull-to'
  export default {
    name: "newActive",
    props:["dayGoodLists",'id','newTime','nowTime','dataList'],
    components:{
      PullTo
    },
    data(){
      return{
        page:1,
        time:'',
        goodList:[],
        BOTTOM_DEFAULT_CONFIG: {
          pullText: "上滑继续加载",
          triggerText: "释放更新",
          loadingText: "加载中,请稍后",
          doneText: "内容已全部展示了",
          failText: "加载失败",
          loadedStayTime: 1000,
          stayDistance: 50,
          triggerDistance: 50,
        },
        limit_id:0,
        group_id:0,
        join_id:0,
        type:1,
        activity_id:0,
        platform:this.$route.query.version,
      }
    },
    methods:{
      click(v){
        var ua = window.navigator.userAgent.toLowerCase();
        if (this._globe.isAndroid) {
          if (window.android != null && typeof window.android != "undefined") {
            /*if (this.platform != "1.6.5") {
              window.android.openGoods(this.type,v.goods_id,this.join_id,this.limit_id,this.group_id);//
            }else{*/
              window.android.openGoods(this.type,v.goods_id,this.join_id,this.limit_id,this.group_id,this.activity_id);//
            /*}*/
          }else if (ua.match(/micromessenger/i) == 'micromessenger'){
            wx.miniProgram.getEnv((res)=> {
              if (res.miniprogram) {
                var url= '../../pages/detail/main?type='+this.type+'&goods_id='+v.goods_id+'&join_id='+this.join_id+'&limit_id='+this.limit_id+'&group_id='+this.group_id+'&activity_id='+this.activity_id;
                wx.miniProgram.navigateTo({
                  url: url,
                })
              }
            })
          } else {
            this.$router.push({
              path:'detail',query:{type:this.type,goods_id:v.goods_id,join_id:this.join_id,limit_id:this.limit_id,
                group_id:this.group_id,activity_id:this.activity_id}
            })
          }
        }
        if (this._globe.isIos) {
          if (window.webkit) {
           /* if (this.platform != "1.2.2") {
              window.webkit.messageHandlers.openGoods.postMessage({type:this.type,goods_id:v.goods_id,join_id:this.join_id,
                limit_id:this.limit_id,group_id:this.group_id});//
            }else{*/
              window.webkit.messageHandlers.openGoods.postMessage({type:this.type,goods_id:v.goods_id,join_id:this.join_id,
                limit_id:this.limit_id,group_id:this.group_id,activity_id:this.activity_id});//
           /* }*/
          }else if (ua.match(/micromessenger/i) == 'micromessenger'){
            wx.miniProgram.getEnv((res)=> {
              if (res.miniprogram) {
                var url= '../../pages/detail/main?type='+this.type+'&goods_id='+v.goods_id+'&join_id='+this.join_id+'&limit_id='+this.limit_id+'&group_id='+this.group_id+'&activity_id='+this.activity_id;
                wx.miniProgram.navigateTo({
                  url: url,
                })
              }
            })
          }else {
            this.$router.push({
              path:'detail',query:{type:this.type,goods_id:v.goods_id,join_id:this.join_id,limit_id:this.limit_id,
                group_id:this.group_id,activity_id:this.activity_id}
            })
          }
        }
      }
    },
    mounted(){
      window.openGoods= this.click();
      if (this.newTime>this.nowTime){
        return time = true
      }
    },
    created(){
      request.dayGoodList(this,this.page,this.id)
    }
  }
</script>

<style scoped lang="scss">
  @media screen and (min-width: 410px) and (max-width: 415px){
    .price{
      margin-top: 6vw !important;
    }
  }
  @media screen and (min-width: 320px) and (max-width: 370px){
    .bodys{
      height: 45vw !important;
    }
    .bodys .left img{
      margin-top: 3vw !important;
    }
    .price{
      margin-top: 4vw !important;
    }
    .sellPrice{
      font-size: 17px;
      position: relative;
      top: 1vw;
    }
    .marketPrice{
      margin-top: -3vw;

    }
  }

  @media screen and (min-width: 375px) and (max-width: 410px){
    .price{
      margin-top: 3vw !important;
    }
  }
  .marketPrice{
    position: relative;
    left: 1vw;
    top: -2vw;
  }
  @media screen and (min-width: 320px) and (max-width: 375px){
    .bodys .right{
      margin-top: 9vw !important;
    }
  }
  .bodys{
    margin-top: 4vw;
    width: 100vw;
    height: 40vw;
    background: #fff;
    border-top-left-radius: 3vw;
    border-top-right-radius: 3vw;
    .left{
      float: left;
      width: 26.67vw;
      height: 26.67vw;
      margin-left: 4vw;
      margin-top: 6.6vw;
      img{
        display: inline-block;
        height: 100%;
        width: 100%;
        margin: 0px auto;
      }
    }
    .right{
      margin-top: 6vw;
      margin-right: 4vw;
      float: right;
      width: 60%;
      .goodName{
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp:2;
        overflow: hidden;
        height: 12vw;
        line-height: 6vw;
      }
      p{
        font-size: 18px;
        color: #ff4c50;
        span{
          color: #666;
          font-size: 13px;
          text-decoration: line-through;
        }
        button{

          height: 8vw;
          width: 18vw;
          font-size: 13px;
          color: #fff;
          -webkit-border-radius: 1.5vw;
          -moz-border-radius: 1.5vw;
          border-radius: 1.5vw;
          float: right;
          margin-top: -2vw;
        }
      }
    }
  }
</style>
